package com.example.douyin.zhibo;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.example.douyin.R;
import com.example.lib_base_mvvm.entity.GiftEntity;

public class GiftLayout extends LinearLayout {
    TextView tvUsername,tvGiftname,tvCount;
    ImageView ivUsername,ivGift;

    public GiftLayout(Context context) {
        super(context);
    }

    public GiftLayout(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        View view = LayoutInflater.from(context).inflate(R.layout.layout_gift, null);
        tvUsername = view.findViewById(R.id.tv_username);
        tvGiftname = view.findViewById(R.id.tv_giftname);
        tvCount = view.findViewById(R.id.tv_count);

        ivUsername = view.findViewById(R.id.iv_username);
        ivGift = view.findViewById(R.id.iv_gift);
        addView(view);

    }

    public GiftLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public GiftLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }


    public void loadTou(String path){
        Glide.with(getContext()).load(path).into(ivUsername);
    }
    public void loadName(String name){
        tvUsername.setText(name+"");
    }
    public void loadCount(int count){
        tvCount.setText("X  "+count);
    }
    public void loadGift(GiftEntity.DataBean bean){
        tvGiftname.setText(bean.getGiftname());
        Glide.with(getContext()).load(bean.getGiftpath()).into(ivGift);
    }
}
